package org.hagen.mmia.yars.agent.utils;

import java.util.TreeMap;

public class DocumentTreeMap extends TreeMap<String, Double> {
    
	/**
	 * 
	 */
	private static final long serialVersionUID = -8789129224758892542L;

	public Double add(String key, Double value) {
		
		Double entry;
		if( (entry = super.get( key )) != null ) {

			entry = value + entry; 
					
			return super.put( key, entry  );

		} else {

			return super.put(key, value);
		}
	}
	
	public Double inc(String key) {
		
		Double entry;
		if( (entry = super.get( key )) != null ) {
			entry += 1.0; 
		} else {
			entry = 1.0;
		}

		return super.put( key, entry  );
	}
}
